<template>
  <view class="merchant-card">
    <!-- 标题部分 -->
    <view class="header">
      <text class="quality-tag">品质</text>
      <text class="shop-name">美团阳光食坊（米线、面条、早点）</text>
    </view>

    <!-- 次要信息 -->
    <view class="meta-info">
      <text class="time">抢单时间：09:00-22:00</text>
      <text class="distance">距您：3.38km</text>
    </view>

    <!-- 活动列表 -->
    <view class="activity-list">
      <block v-for="(item, index) in activities" :key="index">
        <view class="activity-item">
          <view class="activity-left">
            <text class="activity-title">活动{{ index + 1 }}</text>
            <view class="discount-info">
              <text class="amount">满{{ item.full }}返{{ item.return }}</text>
              <text v-if="item.extra" class="extra-tag">{{ item.extra }}</text>
            </view>
            <text class="remaining">剩{{ item.remaining }}%</text>
          </view>
          <button class="grab-btn" @tap="handleGrab(index)">抢单</button>
        </view>
      </block>
    </view>
  </view>
</template>

<script setup>
import { ref } from 'vue'

const activities = ref([
  { full: 20, return: '13.2', remaining: 20, extra: '无需评价' },
  { full: 20, return: '13', remaining: 20 }
])

const handleGrab = (index) => {
  uni.showToast({
    title: `抢单活动${index + 1}`,
    icon: 'none'
  })
}
</script>

<style lang="scss">
.merchant-card {
  padding: 24rpx;
  background: #fff;
  border-radius: 16rpx;
  box-shadow: 0 4rpx 12rpx rgba(0, 0, 0, 0.08);

  .header {
    display: flex;
    align-items: center;
    margin-bottom: 16rpx;

    .quality-tag {
      padding: 4rpx 12rpx;
      background: #ffeeee;
      border-radius: 8rpx;
      color: #e93b3b;
      font-size: 24rpx;
      margin-right: 16rpx;
    }

    .shop-name {
      font-size: 32rpx;
      font-weight: 500;
      color: #333;
    }
  }

  .meta-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 32rpx;

    .time, .distance {
      font-size: 26rpx;
      color: #666;
    }
  }

  .activity-list {
    .activity-item {
      display: flex;
      justify-content: space-between;
      align-items: center;
      padding: 24rpx;
      background: #f8f8f8;
      border-radius: 12rpx;
      margin-bottom: 24rpx;

      &:last-child {
        margin-bottom: 0;
      }

      .activity-left {
        flex: 1;

        .activity-title {
          display: block;
          font-size: 28rpx;
          color: #333;
          margin-bottom: 16rpx;
        }

        .discount-info {
          display: flex;
          align-items: center;
          margin-bottom: 12rpx;

          .amount {
            font-size: 32rpx;
            color: #e93b3b;
            margin-right: 16rpx;
          }

          .extra-tag {
            padding: 4rpx 12rpx;
            background: rgba(233, 59, 59, 0.1);
            border-radius: 8rpx;
            color: #e93b3b;
            font-size: 24rpx;
          }
        }

        .remaining {
          font-size: 26rpx;
          color: #999;
        }
      }

      .grab-btn {
        width: 140rpx;
        height: 60rpx;
        line-height: 60rpx;
        background: #0085ff;
        color: #fff;
        font-size: 28rpx;
        border-radius: 30rpx;
        margin: 0;
        &::after {
          border: none;
        }
      }
    }
  }
}
</style>